﻿<Window x:Class="JenkinsController.View.ServerManagerView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        Title="Server Manager" Height="400" Width="500" ResizeMode="NoResize"
        DataContext="{Binding ServerManager, Source={StaticResource Locator}}" Closed="ServerManagerView_OnClosed"
        Icon="..\Resources\Moustache.ico">
    <DockPanel Margin="10" LastChildFill="True">

        <Grid DockPanel.Dock="Top">
            <TextBlock HorizontalAlignment="Left">Available servers:</TextBlock>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Command="{Binding NewServerCommand}" ToolTip="Click here to a new server." Margin="0,0,5,0">
                    <Image Source="..\Resources\New.ico" Width="16" Height="16" />
                </Button>
                <Button Command="{Binding DeleteServerCommand}" CommandParameter="{Binding SelectedServer}"
                        ToolTip="Click here to delete selected server.">
                    <Image Source="..\Resources\Delete.ico" Width="16" Height="16" />
                </Button>
            </StackPanel>
        </Grid>

        <DockPanel DockPanel.Dock="Bottom" LastChildFill="True">
            <Button Command="{Binding UpdateServerCommand}" CommandParameter="{Binding Text, ElementName=UrlBox}"
                    DockPanel.Dock="Right" Margin="10,0,0,0">
                Update
            </Button>

            <TextBox Name="UrlBox" Text="{Binding SelectedServer.Url, Mode=OneWay}" />
        </DockPanel>

        <ListBox ItemsSource="{Binding Servers}" SelectedItem="{Binding SelectedServer, Mode=TwoWay}" Margin="0,10">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>

                    <StackPanel>
                        <TextBlock FontWeight="Bold" Text="{Binding Node.Description}" />
                        <TextBlock Text="{Binding Url}" />
                    </StackPanel>

                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>


    </DockPanel>
</Window>